--[[ 编码: WMS-13-03 名称: 预收货通知-新增小窗口初始化 作者:HAN 日期:2025-1-29 级别:固定 (说明本段代码在项目中不太会变化) 函数: InitialNewAddDlg 功能: 1)获取当前登录人员的【工厂】中的工厂标识,初始化【仓库】中的下拉框里内容 更改记录: --]] json = require ("json") mobox = require ("OILua_JavelinExt") m3 = require("oi_base_mobox") function InitialNewAddDlg ( strLuaDEID ) local nRet, strRetInfo,factory nRet, factory = m3.GetMyFactory( strLuaDEID ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "GetMyFactory失败! "..factory ) end -- 获取【仓库】 local strCondition = "S_FACTORY = '"..factory.."'" local strOrder = "S_CODE" nRet, strRetInfo = mobox.queryDataObjAttr(strLuaDEID, "Warehouse", strCondition, strOrder,"S_CODE" ) if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【仓库】信息失败! " .. strRetInfo) end if ( strRetInfo == "") then lua.Error( strLuaDEID, debug.getinfo(1), "当前操作人员所属工厂没定义仓库! " ) end local warehouse = {} local n, nCount local success local attrs success, warehouse = pcall( json.decode, strRetInfo) if ( success == false ) then lua.Error( strLuaDEID, debug.getinfo(1), "非法的JSON格式!"..warehouse ) end -- 组织下拉列表选项 local choic_items = '' nCount = #warehouse for n = 1, nCount do attrs = warehouse[n].attrs choic_items = choic_items..'"'..attrs[1].value..'",' end choic_items = lua.trim_laster_char( choic_items ) -- 如果只有一个仓库,那么就默认选这个仓库 local wh_code = '' if ( nCount == 1) then wh_code = attrs[1].value end -- 设置窗口中的 仓库 列表 local setAttr = '[{"attr":"S_WH_CODE","value":"'..wh_code..'","choice_list":['..choic_items..']}]' local strAction = '[{"action_type":"set_dlg_attr","value":'..setAttr..'}]' nRet, strRetInfo = mobox.setAction( strLuaDEID, strAction ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo..' action = '..strAction ) end end